

#include <iostream>
using namespace std;

#include <string>

int _cnt(int n)
{
	int cnt = 0;

	while (n)
	{
		++cnt;
		n /= 10;
	}

	return cnt;
}

void func1(int l, int s)
{
	if (l < s)
		swap(l, s);

	int cnt = _cnt(s);
	while (cnt--)
	{
		int ss = s % 10;

		cout << l * ss << endl;
		s /= 10;
	}
}

void func2(int l, int s)
{
	if (l < s)
		swap(l, s);

	string str = to_string(s);

	reverse(str.begin(), str.end());
	for (int i = 0; i < str.size(); ++i)
	{
		int a = str[i] - '0';
		cout << a * l << endl;
	}
}

class Sln
{
public:
    void _multiply(const string& str, const char c, string& ret, int num0)
    {
        int sz = str.size();

        if ('0' == c)
        {
            for (int i = 0; i < sz + num0; ++i)
            {
                ret += '0';
            }
        }
        else
        {
            int flag = 0, j = 0;
            for (int i = sz - 1; i >= 0; --i)
            {
                int a = str[i] - '0', b = c - '0';
                int mul = a * b + flag;

                ret += mul % 10 + '0';
                flag = mul / 10;
            }
            if (flag)
                ret += (flag + '0');

            reverse(ret.begin(), ret.end());
            while (num0--)
            {
                ret += '0';
            }
        }
    }

    string _sub(string s1, string s2)
    {
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());

        string ret;
        size_t sz1 = s1.size(), sz2 = s2.size();
        size_t i = 0, j = 0;
        int flag = 0;
        while (i < sz1 || j < sz2 || flag)
        {
            int a = i >= sz1 ? 0 : s1[i++] - '0';
            int b = j >= sz2 ? 0 : s2[j++] - '0';
            int sum = a + b + flag;

            ret += sum % 10 + '0';
            flag = sum / 10;
        }
        reverse(ret.begin(), ret.end());

        return ret;
    }

    void _addmul(string& ret, const string* ps, const int n)
    {
        ret = ps[0];
        for (int i = 1; i < n; ++i)
        {
            ret = _sub(ret, ps[i]);
        }
    }

    string multiply(string num1, string num2)
    {
        if (num1 == "0" || num2 == "0")
            return "0";

        string l_str = num1, s_str = num2;
        if (num1.size() < num2.size())
        {
            l_str = num2;
            s_str = num1;
        }

        int s_sz = s_str.size();
        string* ps = new string[s_sz];

        for (int i = s_sz - 1, j = 0; i >= 0; --i)
        {
            _multiply(l_str, s_str[i], ps[j], j);
            ++j;
        }

        string s;
        _addmul(s, ps, s_sz);

        return s;
    }

public:
    int firstUniqChar(string s)
    {
        for (int i = 0; i < s.size(); ++i)
        {
            int index = s.find(s[i]);
            int reverse_index = s.rfind(s[i]);

            if (index == reverse_index)
                return i;
        }

        return -1;
    }
};

int main()
{
	int l = 508591, s = 41609063;
	//cin >> l >> s;

    func1(l, s);
    cout << endl;

    func2(l, s);   
    cout << endl;

    cout << Sln().multiply(string("508591"), string("41609063")) << endl;

	return 0;
}